package com.example.tic_tac_toe_in_android.view;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Languages extends ListActivity {
	
	static String[] arrLanguages = new String[] { "English", "Danish" };
	ArrayAdapter<String> myArrayAdapter;

	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		myArrayAdapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, arrLanguages);
		
		setListAdapter(myArrayAdapter);
		

		// if (savedInstanceState == null) {
		// setListAdapter(new ArrayAdapter<String>(this,
		// android.R.layout.simple_list_item_1, arrLanguages));
		// }

	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {

		super.onListItemClick(l, v, position, id);

		setResult(RESULT_OK,
				new Intent().putExtra("language", arrLanguages[position]));

		finish(); // close the activity 

	}
}
